package com.lin.subject.infra.basic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lin.subject.commom.enums.IsDeletedFlagEnum;
import com.lin.subject.infra.basic.entity.SubjectBrief;
import com.lin.subject.infra.basic.entity.SubjectMultiple;
import com.lin.subject.infra.basic.service.SubjectMultipleService;
import com.lin.subject.infra.basic.mapper.SubjectMultipleDao;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
* @author jeremylin
* @description 针对表【subject_multiple(多选题信息表)】的数据库操作Service实现
* @createDate 2024-10-21 11:12:06
*/
@Service
public class SubjectMultipleServiceImpl extends ServiceImpl<SubjectMultipleDao, SubjectMultiple>
    implements SubjectMultipleService{

    /**
     * 新增题目
     *
     * @param radioList
     */
    @Override
    public void insertList(List<SubjectMultiple> radioList) {
        this.saveBatch(radioList);
    }

    /**
     * 根据条件查询
     *
     * @param multiple
     * @return
     */
    @Override
    public List<SubjectMultiple> queryListByCondition(SubjectMultiple multiple) {
        List<SubjectMultiple> list = lambdaQuery()
                .eq(SubjectMultiple::getSubjectId, multiple.getSubjectId())
                .list();
        return list;
    }

    @Override
    public void deleteSubject(Long id) {
        UpdateWrapper<SubjectMultiple> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().set(SubjectMultiple::getIsDeleted, IsDeletedFlagEnum.DELETED.getCode())
                .eq(SubjectMultiple::getSubjectId, id);

        this.update(updateWrapper);
    }
}




